<?php

if(stristr($_SERVER['PHP_SELF'],".inc.php")) { 
	header("Location:index.php"); 
	exit; 
}

if($_POST['op'] == "my") { //&& isset($_pw)
	//print_r($_POST); 
	if($_pw==trim($User['password'])) {
		if($_POST['newp1'] == $_POST['newp2']) { 
			$newp1 = sha1(stripslashes($_POST['newp1'])); 
			change_user_attr($User['uid'],'password',$newp1);
		} else { 
			unset($goto); 
			$goto = $self."?op=my&m=nc";
			header("Location: ".$goto);
			exit; 		
		}
		$rn = stripslashes($_POST['realname']); 
		change_user_attr($User['uid'],'realname',$rn);
		$goto = $self."?op=my&m=up";
		header("Location: ".$goto);
		exit; 	
	} else { 
		unset($goto); 
		$goto = $self."?op=my&m=X";
		header("Location: ".$goto);
		exit; 
	}
	exit; 
} elseif($_REQUEST['op'] == "my") {
	$_hideForm = TRUE;
	$_hidePosts = TRUE; 
	$id = $auth['uid'];
	$attr = get_user($id); 
?>
	<form action="<?php echo $self; ?>?" method="post" name="myform" style="padding-bottom:0px;">
	<fieldset style="width:350px;margin-left:auto;margin-right:auto;text-align:left;">
		<legend>Account Details</legend>
		<input type="hidden" name="op" value="my" />
		Real Name: <br />
		<input type="text" name="realname" value="<?php echo $User['realname']; ?>" size="50" />
	</fieldset>
	<br />
	<fieldset style="width:350px;margin-left:auto;margin-right:auto;text-align:left;">	
		<legend>Current Password (required)</legend>
		Enter Old Password:<br /><input type="password" name="password" size="50" />
	</fieldset>
	<br />
	<div id="passLink" class="message" style="width:100px;"><a href="#" onclick="togglePass()" style="display:block;">Change Password</a></div>
	<fieldset style="width:350px;margin-left:auto;margin-right:auto;text-align:left;display:none;" id="passID">	
		<legend>Change Password</legend>
		Enter New Password:<br /> <input type="password" name="newp1" size="50" /><br /><br />
		Confirm New Password:<br /> <input type="password" name="newp2" size="50" />
	</fieldset>
	<br />	
	<br />
	<input type="submit" name="delete" class="button" value="<?php echo ucwords($Lang['imSure']);?>" />&nbsp;&nbsp;
	<input type="button" name="cancel" class="button" value="<?php echo ucwords($Lang['noCancel']);?>" onclick="location.href='?'" />&nbsp;&nbsp;
	<br />
	</form>
<?php
}
?>